/*
    PhotoFlip, a free 3d photo managment suite.
    Copyright (C) 2007  Elisée MAURER, Gaétan WALTER
    
    This file is part of PhotoFlip.
    Contact: http://www.photoflip.org/

    PhotoFlip is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PhotoFlip is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PhotoFlip.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef VISUALISATION_HPP_INCLUDED
#define VISUALISATION_HPP_INCLUDED

#include <gtkglmm.h>

#include "library.hpp"

//! Visualisation base-class
/*!
  The visualisation class provides basic framework to expand to create a
  full-featured visualisation.
  
  When creating a visualisation, you should basically implement updateScene()
  and initScene() which are the only two pure virtual functions. You might
  want or need to further modify the base-class by overriding initScene() or
  other virtual functions.
*/
class visualisation {
	protected:
		// general settings
		bool m_wasInit;
		library *m_lib;
		bool m_frames;
		bool m_slideshow;
		int m_photo;
		float m_zoom;
		
		GLuint m_texSelected;
		
		//! Renders a large dark plane.
		virtual void renderFloor();
		//! Renders a photo
		virtual void renderPhoto(GLuint texPhoto, bool selected = false);
		//! Renders a photo frame
		virtual void renderFrame(GLuint texFrame);
	public:
		//! Visualisation constructor.
		visualisation(library *lib, bool frames = true);
		//! Visualisation destructor.
		virtual ~visualisation();
		
		//! Sets selection mark texture
		void setSelectedTexture(GLuint texture);
		
		//! Initializes visualisation scene.
		virtual void initScene();
		//! Updates visualisation scene. Returns true if it wants to be called again in ~10ms.
		virtual bool updateScene() = 0;
		//! Renders visualisation scene.
		virtual void renderScene() = 0;
		
		//! Sets slideshow mode.
		virtual void slideshow(bool state = true);
		//! Sets whether to show frames or not.
		virtual void showFrames(bool state = true);
		//! Sets zoom target.
		virtual void setZoom(float zoom);
		virtual float getZoom();
		//! Sets photo target.
		virtual void moveTo(int photo);
		//! Gets photo target.
		virtual int getPhoto() { return m_photo; }
};

class visuCircular: public visualisation {
	protected:
		float m_angle;
		float m_targetZoom;
		
	public:
		visuCircular(library *lib, bool frames = true);
		~visuCircular();
		
		void initScene();
		bool updateScene();
		void renderScene();
		
		void setZoom(float targetZoom);
		float getZoom();
};

class visuStrew: public visualisation {
	protected:
		float m_x, m_y;
		float m_angleShift;
		float m_targetZoom;
	public:
		visuStrew(library *lib, bool frames = true);
		~visuStrew();
		
		void initScene();
		bool updateScene();
		void renderScene();
		
		void setZoom(float targetZoom);
		float getZoom();
};

class visuFold: public visualisation {
	protected:
		float m_angle;
		float m_targetZoom;
	public:
		visuFold(library *lib, bool frames = true);
		~visuFold();
		
		void initScene();
		bool updateScene();
		void renderScene();
		
		void setZoom(float targetZoom);
		float getZoom();
};

#endif // VISUALISATION_HPP_INCLUDED
